package jp.sinya;

import org.apache.commons.io.IOUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.FileInputStream;
import java.io.IOException;

@WebServlet(name = "DemoServlet7")
public class DemoServlet7 extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String imgPath = "/users/koizumisinya/desktop/workspace/javaspace/myjavawebproject/Demo1/res/cat.jpg";
        FileInputStream fileInputStream = new FileInputStream(imgPath);
        byte[] bytes = IOUtils.toByteArray(fileInputStream);
        response.getOutputStream().write(bytes);
    }
}
